﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Data.SQLite;
using Com.Toook.Common;

public partial class nst_joke_JokeAdd : BasePage
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnAdd_Click(object sender, EventArgs e)
    {
        string sql = "insert into JokePublish(title, content, type) " +
            " values(@title, @content, @type)";
        SQLiteConnection con = SqliteHelper.GetConnection("SQLiteDatabaseMovie");
        SQLiteCommand cmd = new SQLiteCommand(sql, con);
        cmd.Parameters.Add("@title", DbType.String, 30).Value = txtTitle.Text;
        cmd.Parameters.Add("@content", DbType.String).Value = txtContent.Text;
        cmd.Parameters.Add("@type", DbType.Int32).Value = ddlType.SelectedValue;
        try
        {
            con.Open();
            cmd.ExecuteNonQuery();
            txtTitle.Text = "";
            txtContent.Text = "添加成功";
        }
        catch(Exception ex)
        {
            lblMsg.Text = "添加失败" + ex.Message;
            LogHelper.Log.Error(ex);
        }
        finally
        {
            SqliteHelper.CloseDbResource(con, null);
        }
    }
}
